<?php


namespace app\admin\services;


use app\admin\model\LogModel;

class LogService extends BaseService
{
    public static function tableList($p){
        $params=[
            'page'=>$p['pageNo']??1,
            'pageSize'=>$p['pageSize']??10,
            'where'=>[],
            'with'=>[
                'admin'=>function($query){
                    $query->withField(['nickname','account','id']);
                }
            ]
        ];
        if(!empty($p['account']))
            $params['where'][]=['account','like',"%".$p['account']."%"];
        if(!empty($p['searchDate']))
        {
            $params['where'][]=['create_time','>=',strtotime($p['fromTime'])];
            $params['where'][]=['create_time','<=',strtotime($p['toTIme'])];
        }
        $list=LogModel::getList($params);
        $total=LogModel::count($params['where']);
        api_return(200,'success',['list'=>$list,'total'=>$total]);
    }

}
